import format from "@/tools/format";
// import sessionModule from "@/tools/sessionStorage";
export default {

    // 获取路由源数据
    GET_ROUTER_ORIGIN_DATA(state) {
        return state.RouterOriginList
    },

    //  当前路由的顶层路由ID
    GET_CURRENT_ROUTE_TOP_ROUTE_ID(state) {
        return state.CurrentRouterAncestorId
    },
    // 当前路由祖先菜单ID
    Get_ROUTER_ANCESTOR_ID(state) {
        return state.CurrentRouterAncestorId
    },

    // 当前页面标题
    GET_CURRENT_ROUTE_TITLE(state) {
        // 标题
        let title = null
        // 当前页面路由对象
        let CurrentRouterInfo = state.CurrentRouterInfo
        if (CurrentRouterInfo && CurrentRouterInfo.meta && CurrentRouterInfo.meta.title) {
            title = CurrentRouterInfo.meta.title;
        }
        return title;
    },

    // 当前页面标题
    CurrentPageTitle(state) {
        // 标题
        let title = null
        // 当前页面路由对象
        let CurrentRouterInfo = state.CurrentRouterInfo
        if (CurrentRouterInfo && CurrentRouterInfo.meta && CurrentRouterInfo.meta.title) {
            title = CurrentRouterInfo.meta.title;
        }
        return title;
    },
    // 图标侧边栏导航当前选择ID
    CurrentIconNavigatorId(state) {
        return state.currentIconNavigatorId
    },
    // 将state.RouterOriginList格式化为VueRouter格式
    MenusListFormatVueRouter(state) {

        let list = format.ArrayFormatVueRouter(state.RouterOriginList);
        console.log("格式化后路由数据:");
        console.log(list);
        return list
    },
    // 图标侧边栏导航
    IconNavigatorList(state) {
        let list = format.ArrayFormatVueRouter(state.RouterOriginList);
        console.log("格式化后路由数据:");
        console.log(list);
        return list
    },
    // 普通侧边栏导航
    NavigatorMenuList(state) {
        // 路由数组
        let routerList = state.RouterOriginList;
        let list = null
        // 图标侧边栏显示状态
        let navigatorShow = state.navigatorShow
        // 当前选择的图标导航ID
        let AncestorId = state.CurrentRouterAncestorId;
        if (!navigatorShow || !AncestorId) {
            list = format.ArrayFormatVueRouter(routerList);
        } else {
            list = routerList.find((item) => item.meta.id == AncestorId).children ?? [];
        }
        return list;
    },
    // 当前选择的菜单项ID
    CurrentNavigatorId(state) {
        return state.currentNavigatorId
    },
    // 页面顶部配置项
    LayoutHeaderSetting(state) {
        let setting = state.setting
        return setting.header.setting;
    },
    // 菜单侧边栏配置项
    LayoutNavigatorSetting(state) {
        let setting = state.setting
        return setting.navigator.setting;
    },
    // 图标侧边栏配置项
    LayoutIconNavigatorSetting(state) {
        let setting = state.setting
        return setting.IconNavigator.setting;
    },
    // 面包屑配置项
    LayoutBreadCrumbSetting(state) {
        let setting = state.setting
        return setting.Breadcrumb.setting;
    },
    // 路由源数组
    GetRouterOriginList(state) {
        return state.RouterOriginList
    },
    // 登录等待状态
    GetLoginLoadingStatus(state) {
        return state.loginLoading
    },
    // 是否记住密码
    GetRememberPassword(state) {
        return state.RememberPassword
    }
}